<?php include("../components/autoload.php"); ?>
<?php include("../components/functions.php"); ?>
<?php include("../../components/connection.php"); ?>

<?php
	@header('Content-Type: text/html; charset=UTF-8'); 

	$player = new Player(0);
	
	$player->ime = $_POST['name'];
	$player->prezime = $_POST['lastName'];
	$player->dres = $_POST['jersey'];
	$player->datumRodjenja = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
	$player->visina = $_POST['height'];
	$player->tezina = $_POST['weight'];
	$player->ruka = $_POST['arm'];
	
	foreach($_POST['positions'] as $pos) {
		$player->pozicije[] = $pos;
	}
	
	$player->slika = createImage($_FILES["image"], 100, "../../media/players", $player->ime."-".$player->prezime);
	$player->profilnaSlika = createImage($_FILES["profileImage"], 280, "../../media/players/big", $player->ime."-".$player->prezime);
	
	$player->insertIntoDb();
	
	$teamq = "INSERT INTO igra_za (igrac, tim, sezona) VALUES ('".$player->id."', '".$_POST['team']."', '2012')";
	if (mysql_query($teamq)) echo "Dodat igrac u tim!";
	
	
?>